
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="admin.member.MemberDao" scope="page"/>
<jsp:useBean id="code" class="code.codeDao" scope="page"/>
<%@ page import="admin.member.MemberModel" %>
<%@ page import="code.codeModel" %>
<%@ page import="comm.JongTaeUtil"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List" %>
<%
	HashMap	paramMap = new HashMap();
	String	pageName = "lst.jsp";
	int		giSelectPage  	= Integer.parseInt(request.getParameter("txtSelectPage") == null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int		giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock") == null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	String	searchGubn		= request.getParameter("searchGubn") == null ? "" : request.getParameter("searchGubn");
	String	searchValue		= request.getParameter("searchValue") == null ? "" : request.getParameter("searchValue");
	String	id				= request.getParameter("id") == null ? "" : request.getParameter("id");
	out.println("id="+id);
	paramMap.put("id",id);
	
	ArrayList returnList	=  member.getView(paramMap);
	MemberModel model	= new MemberModel();
	List list1 = code.getDtlList("100");
	List list2 = code.getDtlList("101");
	if(returnList != null && returnList.size() > 0){
		model = (MemberModel)returnList.get(0);		
	}
	
	String mode = request.getParameter("mode") == null ? "I" : request.getParameter("mode");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>회원관리</title>
<script type="text/javascript" src="/admin/js/default.js"></script>
<script type="text/javascript" src="/admin/js/jquery-1.3.2.min.js"></script>
<link href="/admin/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
var id = "";
$(document).ready(function(){
	
	<% if (mode.equals("I")){%>
	$('#email3').hide();
	<%}%>	
	$('#lstBtn').click(function() {
		window.location="lst.jsp";
	});
  
	$('#email2').change(function(){
	var val = $('#email2 > option:selected').val();
		if(val == ''){
	      $('#email3').show();
		}else{
		  $('#email3').hide();
		}    
	});  

	$('#idBtn').click(function() {
		window.open("id_check.jsp","idcheck","Width=520,Height=350");
	});
	
});
	function chkPassword(){
		  var obj = document.getElementById("pwd");
		  if(obj.value.search(/[^a-zA-Z0-9-_]/g) != -1){
		    alert('영문이나 숫자만 입력하실 수 있습니다');
		    obj.value = '';
		    return false;
		  }  
		  return true;
	}
		
	function chechk(){
		if($("#id").val() == "" ){
			alert("ID을 입력하세요.");
			return false;
		}else if($("#name").val() == ""){
			alert("이름을 입력하세요.");
			return false;
		}else if($("#pwd").val() == "" ){
			alert("비밀번호을 입력하세요.");
			return false;
		}else if($("#repwd").val() == ""){
			alert("비밀번호확인을 하세요.");
			return false;
		}else if($("#pwd").val() != $("#repwd").val()){
			alert("비밀번호확인을 하세요.");
			return false;
		}else if($("#tel1").val() == "" && $("#tel2").val() == "" && $("#tel3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#hp1").val() == "" && $("#hp2").val() == "" && $("#hp3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#email1").val() == "" && ($("#email2").val() == "" || $("#email3").val() == "") ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if($("#email2").val() == "" ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if(!isEng($("#email1").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else if(!isEng($("#pwd").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else{
		return true;
		}
	}
	
	function open_zipcode(){
		
		window.open("/admin/common/zipcode.jsp","","width=500,height=400,toolbar=no,menubar=no,location=no,scrollbars=yes");
		
	}
	
//-->
</script>
</head>
<body>
<!-- Header  Start -->
<div id="bodywrap">
<div class="all-wrap">
<%@ include file="/admin/common/top.jsp" %>
<div id="right-wrap">
<%@ include file="/admin/common/navi.jsp" %>
<!--Contents Start-->
<div id="content">
<div class="path"><span>home</span> >  회원관리 </div>
<h4>회원</h4>
<p class="sub-text">회원 관리 하실 수 있습니다.</p>
<form name="frm" id="frm" action="dbx.jsp" method="post" onsubmit="return chechk();" >
<input type="hidden" name="mode" value="<%=mode%>" />
<input type="hidden" name="searchGubn" value="<%=searchGubn %>" />
<input type="hidden" name="searchValue" value="<%=searchValue %>" />
<input type="hidden" name="txtSelectPage" value="<%=giSelectPage %>" />
<input type="hidden" name="txtSelectBlock" value="<%=giSelectBlock %>" />
<input type="hidden" name="idx" value="<%=model.getIdx() %>" />
<input type="hidden" name="hiddenid" value="" />

<table class="view-normal" cellpadding="0" cellspacing="0" summary="EVENT" >
        <caption>회원</caption>
          <col width="100px" />
          <col width="528px" />
          <tbody>
          	<tr>
              <th scope="row" >ID</th>
              <td colspan="3"><input name="id" id="id" value="<%=model.getId() %>" title="아이디" type="text" maxlength="12" style="width:150px;"  />&nbsp;<input type="button" value="ID중복체크" class="btn-bg-gray" id="idBtn" /></td>
            </tr>  
            <tr>
              <th scope="row" >비밀번호</th>
              <td colspan="3"><input name="pwd" id="pwd" value="<%=model.getPwd() %>" title="비밀번호" type="password" maxlength="12" style="width:100px;" /></td>
            </tr>                  
            <tr>
              <th scope="row" >비밀번호 확인</th>
              <td colspan="3"><input name="repwd" id="repwd" value="" title="비밀번호확인" type="password" maxlength="12" style="width:100px;" /></td>
            </tr>
            <tr>
              <th scope="row" >이름</th>
              <td colspan="3"><input name="name" id="name" value="<%=model.getName() %>" title="이름" type="text" maxlength="10" style="width:150px;" /></td>
            </tr>
            <tr>
              <th scope="row" >주민번호</th>
              <td colspan="3">
              <%if(!model.getJumin().equals("") && model.getJumin().length() >= 13){%>	
              <input name="jumin1" id="jumin1" value="<%=model.getJumin().substring(0,6) %>" title="주민번호1" type="text" maxlength="6" style="width:100px;" />&nbsp;-&nbsp;
              <input name="jumin2" id="jumin2" value="<%=model.getJumin().substring(6,13) %>" title="주민번호2" type="text" maxlength="7" style="width:100px;" />
              <%}else{ %>  
              <input name="jumin1" id="jumin1" value="" title="주민번호1" type="text" maxlength="6" style="width:100px;" />&nbsp;-&nbsp;
              <input name="jumin2" id="jumin2" value="" title="주민번호2" type="text" maxlength="7" style="width:100px;" />
              <%} %>
              </td>
            </tr>
             <tr>
              <th scope="row" >성별</th>
              <td colspan="3">
              	<input type="radio" name="sex" value="M" <%=JongTaeUtil.checked(model.getSex(),"M") %>/>남
			    <input type="radio" name="sex" value="F" <%=JongTaeUtil.checked(model.getSex(),"F") %>/>여
              </td>              
            </tr> 
            <tr>
			  <th scope="row" >이메일</th>
			  <td colspan="3">
			  <%
			  if(!model.getEmail().equals("")){
              String email[] = model.getEmail().split("@");
              String tmpEmail = "";
              
              if (email[1].equals("hanmail.net")){
               email[1] = "1";
              }else if (email[1].equals("naver.com")){
               email[1] = "2";
              }else if (email[1].equals("yahoo.com")){
               email[1] = "3";
              }else if (email[1].equals("hotmail.com")){
               email[1] = "4";
              }else if (email[1].equals("nate.com")){
               email[1] = "5";
              }else if (email[1].equals("paran.com")){
               email[1] = "6";
              }else if (email[1].equals("dreamwiz.com")){
               email[1] = "7";
              }else if (email[1].equals("empal.com")){
               email[1] = "8";
              }else{
               tmpEmail = email[1];
               email[1] = "9";
              }
			  %>
			    <input type="text" id="email1" name="email1" value="<%=email[0] %>" style="width:60px;ime-mode:inactive;" />
				@
	            <select id="email2" name="email2">
	                <option value="">선택하세요.</option>
	                <option value="" <%if(email[1].equals("9")){ %>selected="selected"<%} %>>직접입력</option>
	                <option value="hanmail.net" <%if(email[1].equals("1")){ %>selected="selected"<%} %>>hanmail.net</option>
					<option value="naver.com" <%if(email[1].equals("2")){ %>selected="selected"<%} %>>naver.com</option>
					<option value="yahoo.com" <%if(email[1].equals("3")){ %>selected="selected"<%} %>>yahoo.com</option>
					<option value="hotmail.com" <%if(email[1].equals("4")){ %>selected="selected"<%} %>>hotmail.com</option>
					<option value="nate.com" <%if(email[1].equals("5")){ %>selected="selected"<%} %>>nate.com</option>
					<option value="paran.com" <%if(email[1].equals("6")){ %>selected="selected"<%} %>>paran.com</option>
					<option value="dreamwiz.com" <%if(email[1].equals("7")){ %>selected="selected"<%} %>>dreamwiz.com</option>
					<option value="empal.com" <%if(email[1].equals("8")){ %>selected="selected"<%} %>>empal.com</option>
	            </select>&nbsp;
	            <input type="text" id="email3" name="email3" value="<%=tmpEmail %>" style="width:60px;" />
			<%}else{ %>
			    <input type="text" id="email1" name="email1" value="" style="width:60px;" />
				@
	            <select id="email2" name="email2">
	                <option value="">선택하세요.</option>
	                <option value="">직접입력</option>
	                <option value="hanmail.net">hanmail.net</option>
					<option value="naver.com">naver.com</option>
					<option value="yahoo.com">yahoo.com</option>
					<option value="hotmail.com">hotmail.com</option>
					<option value="nate.com">nate.com</option>
					<option value="paran.com">paran.com</option>
					<option value="dreamwiz.com">dreamwiz.com</option>
					<option value="empal.com">empal.com</option>
	            </select>&nbsp;
	            <input type="text" id="email3" name="email3" value="" style="width:60px;ime-mode:inactive;" />
			<%}%>			 
			  </td>
			</tr>                
            <tr>
              <th scope="row" >휴대폰번호</th>
              <td colspan="3">	
              <%
              
              	
              		String hp1 = "";
              		String hp2 = "";
              		String hp3 = "";
              		
              		hp1 = model.getHp().substring(0,3);
              		
              		if ( model.getHp().length() == 11){
              			
              			hp2 = model.getHp().substring(3,7);
              			hp3 = model.getHp().substring(7);
              			
              		} else {
              			
              			hp2 = model.getHp().substring(3,6);
              			hp3 = model.getHp().substring(6);
              			
              		}
              		
              %>			
              <select id="hp1" name="hp1" class="mg-l45" style="width:	80px;">
				<option value="010" <%=JongTaeUtil.checked(hp1,"010") %>>010</option>
				<option value="011" <%=JongTaeUtil.checked(hp1,"011") %>>011</option>
				<option value="016" <%=JongTaeUtil.checked(hp1,"016") %>>016</option>
				<option value="017" <%=JongTaeUtil.checked(hp1,"017") %>>017</option>
				<option value="018" <%=JongTaeUtil.checked(hp1,"018") %>>018</option>
				<option value="019" <%=JongTaeUtil.checked(hp1,"019") %>>019</option>
			  </select>
			  &nbsp;-&nbsp;             	 		  
			  <input name="hp2" id="hp2" value="<%=hp2 %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="hp3" id="hp3" value="<%=hp3 %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />
            </tr>
            <tr style="height: 70px;">
              <th scope="row" >주소</th>
              <td colspan="3">
	              <table>
	              <tr>
	              <td colspan="3" style="border-bottom: 0px;">
	              <%
	              	
	              	String zip_code1 = "";
	              	String zip_code2 = "";
	              	
	              	if ( model.getZipcode().length() >= 6 ) {
	              		
	              		zip_code1 = model.getZipcode().substring(0,3);
	              		zip_code2 = model.getZipcode().substring(3);
	              		
	              	}
	              
	              %>
	              	<input name="zipcode1" id="zipcode1" value="<%=zip_code1 %>" title="우편번호" type="text" maxlength="10" style="width:80px;" />-
	              	<input name="zipcode2" id="zipcode2" value="<%=zip_code2 %>" title="우편번호" type="text" maxlength="10" style="width:80px;" />
	              	<input type="button" value="우편번호 찾기" class="btn-bg-gray2" id="idBtn" onclick="open_zipcode();"/>
	              </td>	
	              </tr>
	              <tr>
	              <td colspan="3" style="border-bottom: 0px;">
	              	<input name="addr1" id="addr1" value="<%=model.getAddr1() %>" title="주소" type="text" maxlength="10" style="width:120px;" />
	              	상세주소&nbsp;<input name="addr2" id="addr2" value="<%=model.getAddr2() %>" title="상세주소" type="text" maxlength="10" style="width:200px;" />
	              </td>
	              </tr>
	              </table>
              </td>
            </tr>	
            <tr>
              <th scope="row" >결혼여부</th>
              <td colspan="3">
              	<input type="radio" name="wedding_yn" value="Y" <%=JongTaeUtil.checked(model.getWedding_yn(),"Y") %>>초혼
              	<input type="radio" name="wedding_yn" value="N" <%=JongTaeUtil.checked(model.getWedding_yn(),"N") %>>재혼
              </td>
            </tr>
            <tr>
              <th scope="row" >최종학력</th>
              <td colspan="3">
              	<select name="academic">
			      		<option value="">선택</option>
			      		<option value="1" <%=JongTaeUtil.selected(model.getAcademic(),"1") %>>고등학교졸</option>
			      		<option value="2" <%=JongTaeUtil.selected(model.getAcademic(),"2") %>>전문대</option>
			      		<option value="3" <%=JongTaeUtil.selected(model.getAcademic(),"3") %>>대학교</option>
			      		<option value="4" <%=JongTaeUtil.selected(model.getAcademic(),"4") %>>대학원(재학중)</option>
			      		<option value="5" <%=JongTaeUtil.selected(model.getAcademic(),"5") %>>대학원(중퇴)</option>
			      		<option value="6" <%=JongTaeUtil.selected(model.getAcademic(),"6") %>>대학원(졸업)</option>
			      		<option value="7" <%=JongTaeUtil.selected(model.getAcademic(),"7") %>>박사이상</option>
			      		<option value="8" <%=JongTaeUtil.selected(model.getAcademic(),"8") %>>기타</option>
			     </select>
              </td>
            </tr>
            <tr>
              <th scope="row" >상담시간</th>
              <td colspan="3">
              
			      	
			      	<select name="advice_date">
			      		<option value="">요일</option>
			      		<option value="월" <%=JongTaeUtil.selected(model.getAdvice_date(),"월") %>>월</option>
			      		<option value="화" <%=JongTaeUtil.selected(model.getAdvice_date(),"화") %>>화</option>
			      		<option value="수" <%=JongTaeUtil.selected(model.getAdvice_date(),"수") %>>수</option>
			      		<option value="목" <%=JongTaeUtil.selected(model.getAdvice_date(),"목") %>>목</option>
			      		<option value="금" <%=JongTaeUtil.selected(model.getAdvice_date(),"금") %>>금</option>
			      		<option value="토" <%=JongTaeUtil.selected(model.getAdvice_date(),"토") %>>토</option>
			      		<option value="일" <%=JongTaeUtil.selected(model.getAdvice_date(),"일") %>>일</option>
			      	</select>
			      	<input type="text" name="advice_time" value="<%=model.getAdvice_time() %>"/>&nbsp;예)17시~18시30분
			      	
              </td>
            </tr>
            <tr>
              <th scope="row" >사용자등급</th>
              <td colspan="3">
		        <select id="select-grade" class="selectMain" style="width: 80px;" name="grade">
				<%
				for(int i = 0; i<list2.size(); i++){
					codeModel codemodel = (codeModel)list2.get(i);
					
				%>
				      <option value="<%=codemodel.getCode() %>" <%if(codemodel.getCode().equals(model.getGrade())){%>selected="selected"<%}%>><%=codemodel.getCodename()%></option>
				<%
				} 
				%> 	
				</select>
			  </td>              
            </tr>              
			
          </tbody>       
</table>
<div class="btn-all-align2">
<span class="btn-align"><input type="submit" value="등록" class="btn-bg-gray"  /></span>
<span class="btn-align"><input type="button" value="목록" class="btn-bg-gray" id="lstBtn" /></span>
</div>
</form>
<!--Contents End-->
</div>
</div>
</div>
<!--Footer Start-->
<%@ include file="/admin/common/bottom.jsp" %>
<!--Footer End-->
</body>
</html>